const USERNAME = 'zhang',
    PASSWORD = '123'

exports.check = function(req, res) {
    var { username, password } = req.body
    if (req.session.isLogin) {
        return res.redirect('/login')
    }
    if (USERNAME == username && PASSWORD == password) {
        req.session.isLogin = true
        console.log(req.session)
        res.render('login.html', { username, password })
    } else {
        res.render('login.html', { error: 'wrong username or wrong password' })
    }
}

exports.login = function(req, res) {
    res.render('login.html', { title: 'login', isLogin: !!req.session.isLogin })
}
